﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ep_real_edit.aspx.cs" Inherits="ePioneer_ep_real_edit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <link href="../css/style.css" rel="stylesheet" type="text/css" />
    <script src="Javascript/jq.js" type="text/javascript"></script>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table class="query_form_table">
            <tr>
                <th>
                    战法名称
                </th>
                <td>
                    <asp:TextBox ID="txt_name" runat="server" Width="432px" /><asp:RequiredFieldValidator
                        ID="RequiredFieldValidator1" runat="server" ErrorMessage="战法名称不能为空" ControlToValidate="txt_name"
                        ForeColor="Red"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <th>
                    战法简介
                </th>
                <td>
                    <asp:TextBox ID="txt_brief" runat="server" Width="432px" Height="80" MaxLength="40" />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="战法简介不能为空"
                        ControlToValidate="txt_brief" ForeColor="#FF3300"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <th>
                    推荐理由
                </th>
                <td>
                    <asp:TextBox ID="txt_reason" runat="server" Width="435px" Height="80" /><asp:RequiredFieldValidator
                        ID="RequiredFieldValidator3" runat="server" ErrorMessage="推荐理由不能为空" ControlToValidate="txt_reason"
                        ForeColor="#FF3300"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <th>
                    操作步骤
                </th>
                <td><textarea id="txt_step"  style="width:434px; height:53px" runat="server"></textarea>
                </td>
            </tr>
            <tr>
                <th>
                    经典案例
                </th>
                <td>
                    <asp:TextBox ID="txt_case" runat="server" Height="52px" Width="434px" MaxLength="1000" />
                </td>
            </tr>
            <tr>
                <th>
                    战法图标
                </th>
                <td>
                    <asp:Image ID="Image1" runat="server" />
                    <asp:FileUpload ID="FileUpload1" runat="server" />
                </td>
            </tr>
        </table>
        <table>
            <tr>
                <td>
                    <asp:Button ID="BtnModify" runat="server" Text="保存" OnClick="BtnModify_Click" />
                    &nbsp;
                    <input type="button" value="返回" onclick="location.href='ep_real.aspx'" />
                </td>
            </tr>
        </table>
    </div>
    <input id="hid_id" type="text" style="display: none" runat="server" />
    <script type="text/javascript">
        $(document).ready(function () {
            $('#BtnModify').click(function () {
                var realName = $("#txt_name").val();
                var txtbrief = $("#txt_brief").val();
                var txt_reason = $("#txt_reason").val();
                var txt_step = $("#txt_step").val();
                var txt_case = $("#txt_case").val();
                if (realName == "") {
                    $("#txt_name").val("");
                    $("#txt_name").focus();
                    return false;
                }
                else {
                    if (getByteLen(realName) > 18) {
                        alert("战法名称不能超过9个中文字符");
                        $("#txt_name").focus();
                        return false;
                    }
                }
                if (txtbrief == "") {
                    $("#txt_brief").val("");
                    $("#txt_brief").focus();
                    return false;
                }
                if (txt_reason == "") {
                    $("#txt_reason").val("");
                    $("#txt_reason").focus();
                    return false;
                }
                else {
                    if (getByteLen(txt_reason) > 60) {
                        alert("推荐理由不能超过30个中文字符");
                        $("#txt_reason").focus();
                        return false;
                    }
                }
                var filename = $('#FileUpload1');
                if (filename.val() != "") {
                    var dotArray = filename.val().split(".");
                    if (dotArray.length < 2) {
                        alert("您上传的不是图片文件，请重新上传！");
                        return false;
                    }
                    else {
                        var FileExt;
                        FileExt = dotArray[dotArray.length - 1];
                        if (FileExt == "jpg" || FileExt == "jpeg" || FileExt == "gif" || FileExt == "png") {
                            return true;
                        }
                        else {
                            alert("您上传的不是图片文件或flash文件，请重新上传！");
                            return false;
                        }
                    }
                }
            });
        });
        function getByteLen(str) {
            var l = str.length;
            var n = l;
            for (var i = 0; i < l; i++) {
                if (str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255) {
                    n++;
                }
            }
            return n;
        } 

    </script>
    </form>
</body>
</html>
